import * as Types from '../../actions/actionsTypes';

const initialState = {
  power_count: 0,
  token_count: 0,
  tasks: {},
  caseBook: [],
  img:
    'https://hgbc-1.oss-cn-beijing.aliyuncs.com/head_imgmine%3A1673341577511054383.jpg',
};

export default (home = (state = initialState, action) => {
  switch (action.type) {
    case Types.SET_DATA:
      return {...state, ...action.data};
    case Types.SET_POWER:
      return {...state, power_count: state.power_count + action.power};
    case Types.SET_TOKEN:
      return {...state, token_count: state.token_count + action.token};
    case Types.DELETE_TOKEN:
      return {...state, token_count: state.token_count - action.token};
    case Types.SET_BACK_IMG:
      return {...state, img: action.img};
    case Types.SET_CASEBOOK:
      return {...state, caseBook: action.caseBook};
    case Types.ADD_CASEBOOK:
      return {...state, caseBook: [...state.caseBook, action.caseBook]};
    default:
      return state;
  }
});
